<template>
	<view>
		<view class="addBoard-father">
			<view class="addBoard-son">
				<textarea style="border: 1rpx solid #C0C0C0;" v-model="boardRequest.content" placeholder="请输入公告内容" :maxlength="250"/>
			</view>

		</view>
		<button style="width: 92%;margin-top: 25rpx;" type="primary" @click="addBoard">发布公告</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				boardRequest: {
					orgId: null,
					content: null
				}
			}
		},
		onLoad: function(option) {
			this.boardRequest.orgId = option.orgId
		},
		methods: {
			addBoard() {
				if (this.boardRequest.content == null || this.boardRequest.content == '') {
					uni.showToast({
						title: '公告内容不能为空',
						icon: 'none'
					})
					return
				}
				// 发布公告
				this.$http.request({
					url: '/organizations/web/boards/board',
					method: 'POST',
					data: this.boardRequest
				}).then(res => {
					res = res.data;
					if (res.result) {
						uni.showToast({
							title: res.msg
						})
						this.boardRequest.content = null
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none'
						})
					}
				})
			}
		}
	}
</script>

<style>
	.addBoard-father {
		display: flex;
		justify-content: center;
	}

	.addBoard-son {
		margin-top: 20rpx;
		width: 92%;
		display: flex;
		justify-content: center;
	}
</style>
